package org.jhulk.states;

import java.util.ArrayList;
import java.util.List;

import org.jhulk.sprites.Marine;
import org.jhulk.sprites.Squad;
import org.jhulk.utils.MapTile;
import org.newdawn.slick.tiled.TiledMap;

/**
 * Main container for game information
 * @author jrobbins
 *
 */

public class GameCache 
{
	//The current tileD map for this game
	private TiledMap map;
	
	//The top horizontal border of the selected tile
	private Double mapXForTile = 0.0;
	
	//The left vertical border of the selected tile
	private Double mapYForTile = 0.0;
	
	//The horizontal map coordinate of the cursor 
	private int hovMapX = 0;

	//The vertical map coordinate of the cursor
    private int hovMapY = 0;
	
    //The horizontal tile coordinate of the cursor
    private int hovTileX = 0;

    //The vertical tile coordinate of the cursor
    private int hovTileY = 0;
    
    //The ID of the tile under the cursor 
    private int hovTileId = 0;
    
	//List of all character sprites
    private ArrayList<Squad> squads;
    
    //The highlighted character
    private Marine selectedChar;
    
    //The tile the selected character is currently 'over'
    private MapTile currTile;
    
    private ArrayList<Marine> placementQueue;
    
    private boolean ctrlPressed = false;
	
	
    public boolean isCtrlPressed() {
		return ctrlPressed;
	}

	public void setCtrlPressed(boolean ctrlPressed) {
		this.ctrlPressed = ctrlPressed;
	}

	public MapTile getCurrTile() {
		return currTile;
	}

	public void setCurrTile(MapTile currTile) {
		this.currTile = currTile;
	}

	public Marine getSelectedChar() {
		return selectedChar;
	}

	public void setSelectedChar(Marine selectedChar) {
		this.selectedChar = selectedChar;
	}

	public int getHovTileId() {
		return hovTileId;
	}

	public void setHovTileId(int hovTileId) {
		this.hovTileId = hovTileId;
	}
	
	public ArrayList<Squad> getSquads() {
		return squads;
	}

	public void setSquads(ArrayList<Squad> squads) {
		this.squads = squads;
	}

	public int getHovMapX() {
		return hovMapX;
	}

	public void setHovMapX(int hovMapX) {
		this.hovMapX = hovMapX;
	}

	public int getHovMapY() {
		return hovMapY;
	}

	public void setHovMapY(int hovMapY) {
		this.hovMapY = hovMapY;
	}
	public int getHovTileX() {
		return hovTileX;
	}

	public void setHovTileX(int hovTileX) {
		this.hovTileX = hovTileX;
	}

	public int getHovTileY() {
		return hovTileY;
	}

	public void setHovTileY(int hovTileY) {
		this.hovTileY = hovTileY;
	}
	
	public Double getMapXForTile() {
		return mapXForTile;
	}

	public void setMapXForTile(Double mapXForTile) {
		this.mapXForTile = mapXForTile;
	}

	public Double getMapYForTile() {
		return mapYForTile;
	}

	public void setMapYForTile(Double mapYForTile) {
		this.mapYForTile = mapYForTile;
	}

	public TiledMap getMap() {
		return map;
	}

	public void setMap(TiledMap map) {
		this.map = map;
	}
	
	public void addToPlacementQueue(Squad squad)
	{
		if(placementQueue == null) 
			placementQueue = new ArrayList<Marine>();
			
		for(Marine m : squad.getAllUnits())
		{
			placementQueue.add(m);
		}
	}
	
	public ArrayList<Marine> getPlacementQueue()
	{
		return this.placementQueue;
	}
	
	public void removeFromPlacementQueue(int index)
	{
		placementQueue.remove(index);
	}
}
